/*
 * 用户基础类
 * @author: huangzong
 */
const C = require('../common/common.js')

class Brand {
    constructor () {
    }

    /*
   * 打开基础设置页面
   */
    async openAddBrand (row) {
        return await C.openBrowserWindow('/addBrand', row, {
            transparent: true,
            frame: false,
            // openDevTools: true,
            width: 390,
            height: 400,
            useSpa: true,
            spaModel: 'shop'
        })
    }

    // 新增品牌
    async addBrand (data) {
        if (/^\s*$/.test(data.name)) {
            C.error('品牌名称不能有空格！')
            return false
        } else if (data.belongs == 0) {
            C.error('请选择品牌所属厂家！')
            return false
        }
        return await C.ajax('/shop/brand/addedit', data, 'post')
    }

    // 获取品牌列表
    async getBrandList (filter) {
        return await C.ajax('/shop/brand/brandlist', filter)
    }

    async changeBrandStatus (data) {
        return await C.ajax('/shop/brand/brandstatus', data, 'post')
    }
}

module.exports = new Brand()